package com.zlm.design.combined;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zlm
 * @date 2025/4/21
 */
@Data
public class Province implements PopulationNode{
    private String name;
    private List<PopulationNode> cities = new ArrayList<>();
    public Province(String name) {
        this.name = name;
    }
    public void addCity(City city) {
        cities.add(city);
    }
    @Override
    public int computePopulation() {
        return cities.stream().mapToInt(PopulationNode::computePopulation).sum();
    }
}
